<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<!DOCTYPE html>
<html>
<head>
<title>部门信息</title>
    <style type="text/css">
        .custom_1{
            width: 90px;
            float: left;
            text-align: left;
            margin-right: 15px;
            line-height: 20px;
            color: #666;
            font-size: 12px;
            font-weight: 700;
            padding: 5px;
            white-space: nowrap;
        }
        .custom_2{
            text-align: left;
            margin-right: 15px;
            line-height: 20px;
            color: #666;
            font-size: 12px;
            font-weight: 700;
            padding: 5px;
            white-space: nowrap;
        }
        .checkedBox{
            position: relative;
            top:2px;
        }
        #file_upload1{
            display: inline-block;
        }
        #file_upload2{
            display: inline-block;
        }
        #file_upload3{
            display: inline-block;
        }
        #file_upload1span .uploadify{
            margin-bottom: 0em;
        }
        #file_upload2span .uploadify{
            margin-bottom: 0em;
        }
        #file_upload3span .uploadify{
            margin-bottom: 0em;
        }
    </style>
<t:base type="jquery,easyui,tools"></t:base>

<link rel="stylesheet" href="plug-in/uploadify/css/uploadify.css" type="text/css">
<script type="text/javascript" src="plug-in/uploadify/jquery.uploadify-3.1.js"></script>
<script type="text/javascript" src="plug-in/tools/Map.js"></script>
<script type="text/javascript">
	$(function() {
		$('#cc').combotree({
			url : 'departController.do?setPFunction&selfId=${depart.id}',
            width: 155,
            onSelect : function(node) {
//                alert(node.text);
                changeOrgType();
            }
        });
        if(!$('#cc').val()) { // 第一级，只显示公司选择项
            var orgTypeSelect = $("#orgType");
            var companyOrgType = '<option value="1" <c:if test="${orgType=='1'}">selected="selected"</c:if>><t:mutiLang langKey="common.company"/></option>';
            orgTypeSelect.empty();
            orgTypeSelect.append(companyOrgType);
        } else { // 非第一级，不显示公司选择项
            $("#orgType option:first").remove();
        }
        if($("#id").val()) {
            $('#cc').combotree('disable');
        }
        if('${empty pid}' == 'false') { // 设置新增页面时的父级
            $('#cc').combotree('setValue', '${pid}');
        }

	});
    function changeOrgType() { // 处理组织类型，不显示公司选择项
        var orgTypeSelect = $("#orgType");
        var optionNum = orgTypeSelect.get(0).options.length;
        if(optionNum == 1) {
            $("#orgType option:first").remove();
            var bumen = '<option value="2" <c:if test="${orgType=='2'}">selected="selected"</c:if>><t:mutiLang langKey="common.department"/></option>';
            var gangwei = '<option value="3" <c:if test="${orgType=='3'}">selected="selected"</c:if>><t:mutiLang langKey="common.position"/></option>';
            orgTypeSelect.append(bumen).append(gangwei);
        }
    }


</script>
</head>
<body style="overflow-y: hidden" scroll="no">
<t:formvalid formid="formobj" layout="div" dialog="true" action="systemController.do?saveDepart">
	<input id="id" name="id" type="hidden" value="${depart.id }">
	<fieldset class="step">
        <div class="form">
            <label class="Validform_label"> <t:mutiLang langKey="common.department.name"/>: </label>
            <input name="departname" class="inputxt" type="text" value="${depart.departname }"  datatype="s1-20">
            <span class="Validform_checktip"><t:mutiLang langKey="departmentname.rang1to20"/></span>
        </div>
        <div class="form">
            <label class="Validform_label"> <t:mutiLang langKey="position.desc"/>: </label>
            <input name="description" class="inputxt" value="${depart.description }" ignore="ignore" datatype="s1-100">
        </div>
        <div class="form">
            <label class="Validform_label"> <t:mutiLang langKey="parent.depart"/>: </label>
            <input id="cc" name="TSPDepart.id" value="${depart.TSPDepart.id}">
        </div>
        <div class="form">
            <input type="hidden" name="orgCode" value="${depart.orgCode }">
            <label class="Validform_label"> <t:mutiLang langKey="common.org.type"/>: </label>
            <select name="orgType" id="orgType">
                <option value="1" <c:if test="${orgType=='1'}">selected="selected"</c:if>><t:mutiLang langKey="common.company"/></option>
                <option value="2" <c:if test="${orgType=='2'}">selected="selected"</c:if>><t:mutiLang langKey="common.department"/></option>
                <option value="3" <c:if test="${orgType=='3'}">selected="selected"</c:if>><t:mutiLang langKey="common.position"/></option>
            </select>
        </div>
        <div class="form">
            <label class="Validform_label"> <t:mutiLang langKey="common.mobile"/>: </label>
            <input name="mobile" class="inputxt" value="${depart.mobile }" ignore="ignore" datatype="/^(\(\d{3,4}\)|\d{3,4}-|\s)?\d{7,14}$/" errormsg="电话号码格式错误">
        </div>
        <div class="form">
            <label class="Validform_label"> <t:mutiLang langKey="common.fax"/>: </label>
            <input name="fax" class="inputxt" value="${depart.fax }" ignore="ignore" datatype="/^[+]{0,1}(\d){1,3}[ ]?([-]?((\d)|[ ]){1,12})+$/" errormsg="传真号码格式错误">
        </div>
        <div class="form">
            <label class="Validform_label"> <t:mutiLang langKey="common.address"/>: </label>
            <input name="address" class="inputxt" value="${depart.address }" datatype="s1-50">
            <span class="Validform_checktip"><t:mutiLang langKey="departmentaddress.rang1to50"/></span>
        </div>
        <div class="form" style="line-height: 30px;">
            <label class="custom_1">业务角色:</label>
            <input name="carrier" class="checkedBox" type="checkbox" value="1" <c:if test="${depart.carrier == 1}">checked="checked"</c:if> >
            <label class="custom_2">服务商</label>
            <input name="service"class="checkedBox" type="checkbox" value="1" <c:if test="${depart.service == 1}">checked="checked"</c:if> >
            <label class="custom_2">承运商</label>
            <input name="dataOwner" class="checkedBox" type="checkbox"  value="1" <c:if test="${depart.dataOwner == 1}">checked="checked"</c:if> >
            <label class="custom_2">数据主体</label>
            <input name="advance" class="checkedBox" type="checkbox"  value="1" <c:if test="${depart.advance == 1}">checked="checked"</c:if> >
            <label class="custom_2">运费垫付机构</label>
        </div>
        <div class="form">
            <label class="Validform_label">营业执照号: </label>
            <input name="businessLicense" class="inputxt" ignore="ignore" value="${depart.businessLicense }" datatype="n15-15" errormsg="营业执照号为15位数字">
            <input type="hidden" name = "businessLicenseSrc" ignore="ignore" value="${depart.businessLicenseSrc}" datatype="/upload/" nullmsg="请上传照片" errormsg="请上传照片">
            <label class="custom_2">上传照片: </label>
            <span id="file_upload1span">
                <div id="file_upload1" class="uploadify" style="height:25px;width:76px;"></div>
            </span>
            <span class="Validform_checktip"></span>
        </div>
        <div class="form">
            <label class="Validform_label">组织机构号: </label>
            <input name="organizational" class="inputxt" ignore="ignore" value="${depart.organizational }" datatype="n8-8" errormsg="组织机构号为8位数字">
            <input type="hidden" name = "organizationalSrc" ignore="ignore" value="${depart.organizationalSrc}" datatype="/upload/" nullmsg="请上传照片" errormsg="请上传照片">
            <label class="custom_2">上传照片:</label>
            <span id="file_upload2span">
                <div id="file_upload2" class="uploadify" style="height:25px;width:76px;"></div>
            </span>
            <span class="Validform_checktip"></span>
        </div>
        <div class="form">
            <label class="Validform_label">法人身份证号: </label>
            <input name="legalCard" class="inputxt" ignore="ignore" value="${depart.legalCard }" datatype="/^(\d{15}$|^\d{18}$|^\d{17}(\d|X|x))$/" errormsg="请输入身份证号">
            <input type="hidden" name = "legalCardSrc" ignore="ignore" value="${depart.legalCardSrc}" datatype="/upload/" nullmsg="请上传照片" errormsg="请上传照片">
            <label class="custom_2">上传照片: </label>
            <span id="file_upload3span">
                <div id="file_upload3" class="uploadify" style="height:25px;width:76px;"></div>
            </span>
            <span class="Validform_checktip"></span>
        </div>
        <div class="form">
            <label class="Validform_label">推荐码: ${depart.reccodeEntity.recCode }</label>
        </div>
	</fieldset>
</t:formvalid>
</body>
<script type="text/javascript">
    $(function(){
        $('#file_upload1').uploadify({
            buttonText:'选择',
            auto:true,
            progressData:'speed',
            multi:false,
            height:25,
            width:76,
            overrideEvents:['onDialogClose'],
            fileTypeDesc:'文件格式:',
            queueID:'filediv',
            fileTypeExts:'*.jpg;*,jpeg;*.png;*.gif;*.bmp;*.ico;*.tif',
            fileSizeLimit:'15MB',
            swf:'plug-in/uploadify/uploadify.swf',
            uploader:'departController.do?upload',
            onUploadStart : function(file) { } ,
            onQueueComplete : function(queueData) {
            },
            onUploadSuccess : function(file, data, response) {
                var d=$.parseJSON(data);
                if(d.status == "1"){
                    $("#file_upload1-button span").html("已上传");
                    $("input[name='businessLicenseSrc']").val(d.urls[0]);
                }else{
                    $("#file_upload1-button span").html("上传失败");
                }
                var win = frameElement.api.opener;
                win.tip(d.message);
            },
            onFallback : function(){
                tip("您未安装FLASH控件，无法上传图片！请安装FLASH控件后再试")
            },
            onSelectError : function(file, errorCode, errorMsg){
                switch(errorCode) {
                    case -100:tip("上传的文件数量已经超出系统限制的"+$('#file_upload1').uploadify('settings','queueSizeLimit')+"个文件！");
                        break;
                    case -110:tip("文件 ["+file.name+"] 大小超出系统限制的"+$('#file_upload1').uploadify('settings','fileSizeLimit')+"大小！");
                        break;
                    case -120:tip("文件 ["+file.name+"] 大小异常！");
                        break;
                    case -130:tip("文件 ["+file.name+"] 类型不正确！");
                        break;
                }
            },
            onUploadProgress : function(file, bytesUploaded, bytesTotal, totalBytesUploaded, totalBytesTotal) { }
        });

        $('#file_upload2').uploadify({
            buttonText:'选择',
            auto:true,
            progressData:'speed',
            multi:false,
            height:25,
            width:76,
            overrideEvents:['onDialogClose'],
            fileTypeDesc:'文件格式:',
            queueID:'filediv',
            fileTypeExts:'*.jpg;*,jpeg;*.png;*.gif;*.bmp;*.ico;*.tif',
            fileSizeLimit:'15MB',
            swf:'plug-in/uploadify/uploadify.swf',
            uploader:'departController.do?upload',
            onUploadStart : function(file) { } ,
            onQueueComplete : function(queueData) {

            },
            onUploadSuccess : function(file, data, response) {
                var d=$.parseJSON(data);
                if(d.status == "1"){
                    $("#file_upload2-button span").html("已上传");
                    $("input[name='organizationalSrc']").val(d.urls[0]);
                }else{
                    $("#file_upload2-button span").html("上传失败");
                }
                var win = frameElement.api.opener;
                win.tip(d.message);
            },
            onFallback : function(){
                tip("您未安装FLASH控件，无法上传图片！请安装FLASH控件后再试")
            },
            onSelectError : function(file, errorCode, errorMsg){
                switch(errorCode) {
                    case -100:tip("上传的文件数量已经超出系统限制的"+$('#file_upload2').uploadify('settings','queueSizeLimit')+"个文件！");
                        break;
                    case -110:tip("文件 ["+file.name+"] 大小超出系统限制的"+$('#file_upload2').uploadify('settings','fileSizeLimit')+"大小！");
                        break;
                    case -120:tip("文件 ["+file.name+"] 大小异常！");
                        break;
                    case -130:tip("文件 ["+file.name+"] 类型不正确！");
                        break;
                }
            },
            onUploadProgress : function(file, bytesUploaded, bytesTotal, totalBytesUploaded, totalBytesTotal) { }
        });

        $('#file_upload3').uploadify({
            buttonText:'选择',
            auto:true,
            progressData:'speed',
            multi:false,
            height:25,
            width:76,
            overrideEvents:['onDialogClose'],
            fileTypeDesc:'文件格式:',
            queueID:'filediv',
            fileTypeExts:'*.jpg;*,jpeg;*.png;*.gif;*.bmp;*.ico;*.tif',
            fileSizeLimit:'15MB',
            swf:'plug-in/uploadify/uploadify.swf',
            uploader:'departController.do?upload',
            onUploadStart : function(file) { } ,
            onQueueComplete : function(queueData) {
            },
            onUploadSuccess : function(file, data, response) {
                var d=$.parseJSON(data);
                if(d.status == "1"){
                    $("#file_upload3-button span").html("已上传");
                    $("input[name='legalCardSrc']").val(d.urls[0]);
                }else{
                    $("#file_upload3-button span").html("上传失败");
                }
                var win = frameElement.api.opener;
                win.tip(d.message);
            },
            onFallback : function(){
                tip("您未安装FLASH控件，无法上传图片！请安装FLASH控件后再试")
            },
            onSelectError : function(file, errorCode, errorMsg){
                switch(errorCode) {
                    case -100:tip("上传的文件数量已经超出系统限制的"+$('#file_upload3').uploadify('settings','queueSizeLimit')+"个文件！");
                        break;
                    case -110:tip("文件 ["+file.name+"] 大小超出系统限制的"+$('#file_upload3').uploadify('settings','fileSizeLimit')+"大小！");
                        break;
                    case -120:tip("文件 ["+file.name+"] 大小异常！");
                        break;
                    case -130:tip("文件 ["+file.name+"] 类型不正确！");
                        break;
                }
            },
            onUploadProgress : function(file, bytesUploaded, bytesTotal, totalBytesUploaded, totalBytesTotal) { }
        });
    });
</script>
</html>
